<?php


namespace app\common\model;


use think\Model;

class Message extends Model
{
    public function addItem($data){
        $res = $this->save($data);
        return $res;
    }
    public function getAllList($paging){
        $count = $this->count();
        $total = ceil($count/$paging['num']);
        $res = $this->order('id','desc')->limit(($paging['current_page']-1)*$paging['num'],$paging['num'])->select();
        $pageInfo = [
            "current_page"=>$paging['current_page'],
            "total"=>$total
        ];
        $result = [
            'pageInfo' =>$pageInfo,
            'list' => $res
        ];
        return $result;
    }
    public function getDetailByWhere($where){
        $result = $this->where($where)->find();
        return $result;
    }
    public function removeByWhere($where){
        $result = $this->where($where)->delete();
        return $result;
    }
}